<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Services\MeetService;
use Illuminate\Http\Request;

class MeetController extends Controller
{
    private $meetService;
    public function __construct(MeetService $meetService)
    {
        $this->meetService = $meetService;
    }
    public function meetList(Request $request)
    {
        $params = $request->input();
        $result = $this->meetService->meetList($params);
        return $this->responseSuccess($result);
    }


    public function addMeet(Request $request)
    {
        $params = $request->input();
        if(isset($params['id']) && !empty($params['id'])){
            $result = $this->meetService->updateMeet($params);
            if($result)
                return $this->responseSuccess($result);
            else
                return $this->responseError("更新失败，请重试！");
        }else{
            $result = $this->meetService->insertMeet($params);
            if($result)
                return $this->responseSuccess($result);
            else
                return $this->responseError("新增失败，请重试！");
        }

    }

    public function meetStatusUpdate(Request $request)
    {
        $params = $request->input();
        $result = $this->meetService->meetStatusUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    public function addFeedback(Request $request)
    {
        $params = $request->input();
        $result = $this->meetService->addFeedback($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError("更新失败，请重试！");
    }
}
